/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import entity.Recetasinsumos;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author FRANCO
 */
@Stateless
public class RecetasinsumosFacade extends AbstractFacade<Recetasinsumos> implements RecetasinsumosFacadeRemote {
    @PersistenceContext(unitName = "socafe-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public RecetasinsumosFacade() {
        super(Recetasinsumos.class);
    }

    @Override
    public List<Recetasinsumos> findByIdinsumo(int idInsumo) {
        return getEntityManager().createNamedQuery("Recetasinsumos.findByIdinsumo").setParameter("idinsumo", idInsumo).getResultList();
    }
    
    public List<Recetasinsumos> FindByID(int o)
    {
        return getEntityManager().createNamedQuery("Recetasinsumos.findByIdreceta").setParameter("idreceta", o).getResultList();
    }
    
    public void EliminarPorIdReceta(int idReceta)
    {
        getEntityManager().createNativeQuery("Delete from RecetasInsumos where idreceta = :idreceta").setParameter("idreceta", idReceta);
    }
    
}
